
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
 using LPV_POS.Module;
 using LPV_POS.mh_pos.mh_danhmuc;
using System.Resources;
using System.Globalization;

namespace LPV_POS.mh_pos
{
    public partial class frmBH_CAU_HINH : Form
    {
        CultureInfo culture;
        string str_lang = "";
        //public string ma = "";//PK_: giá trị này dc truyền từ bảng danh sách, trường hợp EDIT
        DataTable tbMain = new DataTable();

        #region "Muti language"

        private void SetLanguage_banhang(string cultureName)
        {
            try
            {
                culture = CultureInfo.CreateSpecificCulture(cultureName);
                ResourceManager rm = new ResourceManager("LPV_POS.Muti_language.MyResource", typeof(mh_banhang6_PhuThu).Assembly);
                groupControl3.Text = rm.GetString("cauhinhbanhang", culture);
                chkNGAY_LAM_VIEC_LA_NGAY_HE_THONG.Text = rm.GetString("ngaylamvieclahethong", culture);
                chkHIEN_THI_TIEN_KHACH_DUA.Text = rm.GetString("hienthitienkhachdua", culture);
                chkPHAI_VAO_CA_KHI_BAN_HANG.Text = rm.GetString("phaivaocakhibanhang", culture);
                chkKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH.Text = rm.GetString("khongcanvaocakhivaochuongtrinh", culture);
                chkGOP_MON_CUNG_TEN_KHI_DAT_HANG.Text = rm.GetString("gopmoncungtenkhidathang", culture);
                chkCHO_PHEP_MO_BAN_CA_KHAC.Text = rm.GetString("chophepmobancakhac", culture);
                check_loaidichvu.Text = rm.GetString("hienthiloaidichvutrenban", culture);
                chkLuuBanTrongKhiTamTinh.Text = rm.GetString("luubantrongkhitamtinh", culture);
                lblHINH_THUC_BAN_HANG_combo.Text = rm.GetString("hinhthucbanhang", culture);
                label1.Text = rm.GetString("khomacdinh", culture);
                chkHIEN_THI_TIEN_THOI.Text = rm.GetString("hienthitienthoi", culture);
                chkPHAI_NHAP_LYDO_TRA_MON.Text = rm.GetString("nhaplydotramon", culture);
                chkPHAI_NHAP_LYDO_HUY_BILL.Text = rm.GetString("nhaplydohuybill", culture);
                lblSO_THAP_PHAN.Text = rm.GetString("sothapphan", culture);
                check_moket.Text = rm.GetString("moketkhithanhtoan", culture);
                chkHien_Thi_DVT.Text = rm.GetString("hienthidonvitinh", culture);
                chk_PrintBill_COM_English.Text = rm.GetString("inbillcomtienganh", culture);
                chk_Chuyen_DenPhong_KhiThanhToan.Text = rm.GetString("chuyenbilldenphongdangokhithanhtoan", culture);
                label11.Text = rm.GetString("mamay", culture);
                label2.Text = rm.GetString("giamacdinh", culture);
                chkThanh_Toan_Bang_The_Tra_Truoc.Text = rm.GetString("thanhtoanbangthetratruoc", culture);
                rbtHienThiGioRa.Text = rm.GetString("hienthigiora", culture);
                chkCAPNHAT_LAILO.Text = rm.GetString("capnhatlailo", culture);
                chkCAPNHAT_TONKHO_HANGHOA.Text = rm.GetString("capnhattonkhohanghoa", culture);
                chkCAPNHAT_TONKHO_NGUYENLIEU.Text = rm.GetString("capnhattonkhonguyenlieu", culture);
                chkKhongDuoc_Sua_GioRaVao.Text = rm.GetString("khongsuagioravao", culture);
                chk_VAT_Chi_Tinh_Tong_Tien.Text = rm.GetString("vatchitinhtrentongtien", culture);
                //label3.Text = rm.GetString("lamtronvat", culture).Replace("VAT","").Trim();

                btnHienThi_BaoCao.Text = rm.GetString("hienthibaocao", culture);
                btnDanhsach_Ngayle.Text = rm.GetString("danhsachngayle", culture);
                groupControl2.Text = rm.GetString("vat", culture);
                chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Text = rm.GetString("kichhoat", culture);
                chkTHUE_TU_CHON.Text = rm.GetString("thuetuchon", culture);
                chkTHUE_APDUNG.Text = rm.GetString("apdung", culture);
                lblTHUE_AN_TAI_CHO.Text = rm.GetString("antaiquan", culture) + "(%)";
                lblTHUE_MANG_VE.Text = rm.GetString("mangve", culture) + "(%)";
                groupControl4.Text = rm.GetString("phidichvu", culture);
                chkPHI_DICH_VU.Text = rm.GetString("kichhoat", culture);
                groupControl1.Text = rm.GetString("tientip", culture);
                chkTIEN_TIP.Text = rm.GetString("kichhoat", culture);
                chkTIEN_TIP_TUYCHON.Text = rm.GetString("tuychon", culture);
                chkTIEN_TIP_VAT.Text = rm.GetString("apdung", culture) + "(%)";
                btn_luu.Text = rm.GetString("luu", culture);
                btn_thoat.Text = rm.GetString("thoat", culture);
                chkSo_Khach_Tren_Ban.Text = rm.GetString("sokhachtrenban", culture);
                chkHienThi_TongTien_TrenBan.Text = rm.GetString("hienthitongtien", culture);
                btnHienThi_BanHang.Text = rm.GetString("hienthibanhang", culture);
                chkNhan_Vien_Phuc_Vu.Text = rm.GetString("nhanvienphucvu", culture);
               //chkNhan_Vien_Phuc_Vu.Text = rm.GetString("nhanvienphucvu", culture);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Note");
            }

        }

        #endregion

        #region"    frmBH_CAU_HINH"
        public frmBH_CAU_HINH()
        {
            InitializeComponent();
            culture = CultureInfo.CurrentCulture;
        }
        #endregion

        #region"    frmBH_CAU_HINH_Load"
        public void frmBH_CAU_HINH_Load(object sender, EventArgs e)
        {
            cpublic ocpublic = new cpublic();
            thuvien othuvien = new thuvien();
            str_lang = ocpublic.Registry_Get("mh_main_lang");
            if (str_lang == "")
                str_lang = "vi-VN";
            SetLanguage_banhang(str_lang);

            string sSQL = "SELECT * FROM DM_KHOHANG ORDER BY OBJID";
            DataTable tbKHO_MACDINH = othuvien.SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL" }, new object[] { sSQL });
            cboKHO_MACDINH.DataSource = tbKHO_MACDINH;

            DataTable tbBH_CAU_HINH = othuvien.SP_SelectDataTable("sp_BH_CAU_HINH", new string[] { "@flag" }, new object[] { 7 });
            com_giamacdinh.DataSource = tbBH_CAU_HINH;
            com_giamacdinh.DisplayMember = "GIA_TEN";
            com_giamacdinh.ValueMember = "GIA";
            //
            sSQL = "SELECT GIA_TRI = 0, dk.OBJID, dk.OBJNAME  FROM DM_KHUVUC dk";
            DataTable tbDM_KHUVUC = othuvien.SP_SelectDataTable("SP_EXECUTESQL", new string[] { "@sSQL" }, new object[] { sSQL });
            float fgiatri=0;
            foreach (DataRow dr in tbDM_KHUVUC.Rows)
            {
                float.TryParse(ocpublic.Registry_Get("SC_DEFAULT_KHU" + dr["OBJID"]) + "", out fgiatri);
                dr["GIA_TRI"] = fgiatri;
            }
            grdPhiDivhVu.DataSource = tbDM_KHUVUC;

            this.showinfo();

            //
            //this.toolTip1.SetToolTip(numDOIGIO_LAMVIEC_TRONGNGAY, "VD: bán hàng đến 3h sáng hôm sau \nMà vẫn tính doanh thu cho ngày hôm nay\nThì giá trị nhập = 3.");
        }
        #endregion

        #region"    các hàm load dữ liệu"
        #region"    showdata"
        void showdata()
        {

            thuvien oclsData = new thuvien();//lớp truy xuat du lieu 
            tbMain = oclsData.SP_SelectDataTable("sp_BH_CAU_HINH",
                               new string[] { "@flag" },//, "@ID" 
                               new object[] { 4 });//, ma 

        }
        #endregion

        #region"    showinfo"
        void showinfo()
        {

            this.showdata();
            if (tbMain.Rows.Count == 0)
            {
                chkNGAY_LAM_VIEC_LA_NGAY_HE_THONG.Checked = false;
                //dtpNGAY_LAM_VIEC.Value = DateTime.Now;
                //dtpNGAY_LAM_VIEC.Checked = false;                
                cboHINH_THUC_BAN_HANG_combo.SelectedIndex = 1;
                chkHIEN_THI_TIEN_THOI.Checked = false;
                chkHIEN_THI_TIEN_KHACH_DUA.Checked = false;
                chkPHAI_VAO_CA_KHI_BAN_HANG.Checked = false;
                chkKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH.Checked = false;
                chkKHONG_XOA_MON_SAU_TAM_TINH.Checked = false;
                chkPHAI_NHAP_LYDO_TRA_MON.Checked = false;
                chkGOP_MON_CUNG_TEN_KHI_DAT_HANG.Checked = false;
                numSO_THAP_PHAN.Value = 0;
                //numDOIGIO_LAMVIEC_TRONGNGAY.Value = 0;
                chkKHONG_MO_KET_KHI_THANH_TOAN_ZERO.Checked = false;
                chkCHO_PHEP_MO_BAN_CA_KHAC.Checked = false;
                chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Checked = false;
                chkTHUE_TU_CHON.Checked = false;
                chkTHUE_APDUNG.Checked = false;
                numTHUE_AN_TAI_CHO.Value = 0;
                numTHUE_MANG_VE.Value = 0;
                chkTIEN_TIP.Checked = false;
                chkTIEN_TIP_TUYCHON.Checked = false;
                chkTIEN_TIP_VAT.Checked = false;
                numTIEN_TIP_VAT_PHANTRAM.Value = 0;
                chkPHI_DICH_VU.Checked = false;
                cboPHI_DICH_VU_PHANTRAM.SelectedIndex = 0;
                cboPHI_DICH_VU_PHANTRAM.Enabled = false;
                check_moket.Checked = false;
                txt_mamay.Text = "";
                com_giamacdinh.Text = "";
                chkCAPNHAT_TONKHO_HANGHOA.Checked = false;
                chkCAPNHAT_TONKHO_NGUYENLIEU.Checked = false;
                chkCAPNHAT_LAILO.Checked = false;
                chkHien_Thi_DVT.Checked = false;
                chk_PrintBill_COM_English.Checked = false;
                chk_Chuyen_DenPhong_KhiThanhToan.Checked = false;
                chkApDung_TheoKhu.Checked = false;
                return;
            }
            chkNGAY_LAM_VIEC_LA_NGAY_HE_THONG.Checked = Boolean.Parse("" + tbMain.Rows[0]["NGAY_LAM_VIEC_LA_NGAY_HE_THONG"] + "");
            //dtpNGAY_LAM_VIEC.Checked = tbMain.Rows[0]["NGAY_LAM_VIEC"] + "" != "";
            //if (dtpNGAY_LAM_VIEC.Checked)
            //    dtpNGAY_LAM_VIEC.Text = tbMain.Rows[0]["NGAY_LAM_VIEC"] + "";
            cboHINH_THUC_BAN_HANG_combo.SelectedIndex = int.Parse(tbMain.Rows[0]["HINH_THUC_BAN_HANG_combo"] + "");
            chkHIEN_THI_TIEN_THOI.Checked = Boolean.Parse("" + tbMain.Rows[0]["HIEN_THI_TIEN_THOI"] + "");
            chkHIEN_THI_TIEN_KHACH_DUA.Checked = Boolean.Parse("" + tbMain.Rows[0]["HIEN_THI_TIEN_KHACH_DUA"] + "");
            chkPHAI_VAO_CA_KHI_BAN_HANG.Checked = Boolean.Parse("" + tbMain.Rows[0]["PHAI_VAO_CA_KHI_BAN_HANG"] + "");
            chkKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH.Checked = Boolean.Parse("" + tbMain.Rows[0]["KHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH"] + "");
            chkKHONG_XOA_MON_SAU_TAM_TINH.Checked = Boolean.Parse("" + tbMain.Rows[0]["KHONG_XOA_MON_SAU_TAM_TINH"] + "");
            chkPHAI_NHAP_LYDO_TRA_MON.Checked = Boolean.Parse("" + tbMain.Rows[0]["PHAI_NHAP_LYDO_TRA_MON"] + "");
            chkPHAI_NHAP_LYDO_HUY_BILL.Checked = tbMain.Rows[0]["PHAI_NHAP_LYDO_HUY_BILL"] + "" == "True";
            chkGOP_MON_CUNG_TEN_KHI_DAT_HANG.Checked = Boolean.Parse("" + tbMain.Rows[0]["GOP_MON_CUNG_TEN_KHI_DAT_HANG"] + "");
            numSO_THAP_PHAN.Value = decimal.Parse(string.Concat("0" + tbMain.Rows[0]["SO_THAP_PHAN"]).Replace("0-", "-"));
            //numDOIGIO_LAMVIEC_TRONGNGAY.Value = decimal.Parse(string.Concat("0" + tbMain.Rows[0]["DOIGIO_LAMVIEC_TRONGNGAY"]).Replace("0-", "-"));
            chkKHONG_MO_KET_KHI_THANH_TOAN_ZERO.Checked = Boolean.Parse("" + tbMain.Rows[0]["KHONG_MO_KET_KHI_THANH_TOAN_ZERO"] + "");
            chkCHO_PHEP_MO_BAN_CA_KHAC.Checked = Boolean.Parse("" + tbMain.Rows[0]["CHO_PHEP_MO_BAN_CA_KHAC"] + "");

            chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Checked = Boolean.Parse("" + tbMain.Rows[0]["GIA_MOI_MAT_HANG_KHONG_GOM_THUE"] + "");
            chkTHUE_TU_CHON.Checked = Boolean.Parse("" + tbMain.Rows[0]["THUE_TU_CHON"] + "");
            numVAT_MAC_DINH.Value = decimal.Parse(string.Concat("0" + tbMain.Rows[0]["VAT_MAC_DINH"]).Replace("0-", "-"));

            chkTHUE_APDUNG.Checked = Boolean.Parse("" + tbMain.Rows[0]["THUE_APDUNG"] + "");
            numTHUE_AN_TAI_CHO.Value = decimal.Parse(string.Concat("0" + tbMain.Rows[0]["THUE_AN_TAI_CHO"]).Replace("0-", "-"));
            numTHUE_MANG_VE.Value = decimal.Parse(string.Concat("0" + tbMain.Rows[0]["THUE_MANG_VE"]).Replace("0-", "-"));
            chkTIEN_TIP.Checked = Boolean.Parse("" + tbMain.Rows[0]["TIEN_TIP"] + "");
            chkTIEN_TIP_TUYCHON.Checked = Boolean.Parse("" + tbMain.Rows[0]["TIEN_TIP_TUYCHON"] + "");
            chkTIEN_TIP_VAT.Checked = Boolean.Parse("" + tbMain.Rows[0]["TIEN_TIP_VAT"] + "");
            numTIEN_TIP_VAT_PHANTRAM.Value = decimal.Parse(string.Concat("0" + tbMain.Rows[0]["TIEN_TIP_VAT_PHANTRAM"]).Replace("0-", "-"));

            chkPHI_DICH_VU.Checked = Boolean.Parse("" + tbMain.Rows[0]["PHI_DICH_VU"] + "");
            cboPHI_DICH_VU_PHANTRAM.Text = tbMain.Rows[0]["PHI_DICH_VU_PHANTRAM"] + "";
            cboPHI_DICH_VU_PHANTRAM.Enabled = chkPHI_DICH_VU.Checked;

            //cboKHO_MACDINH.Text = tbMain.Rows[0]["KHO_MACDINH"] + "";
            string objNAME_KHO = new cpublic().Registry_Get("frmBH_CAU_HINHcboKHO_MACDINH");
            cboKHO_MACDINH.SelectedValue = objNAME_KHO;

            cpublic ocpublic = new cpublic();
            rbtHienThiGioRa.Checked = ocpublic.Registry_Get("rbtHienThiGioRa") == "True";
            chkThanh_Toan_Bang_The_Tra_Truoc.Checked = ocpublic.Registry_Get("chkThanh_Toan_Bang_The_Tra_Truoc") == "True";
            chkKhongDuoc_Sua_GioRaVao.Checked = ocpublic.Registry_Get("chkKhongDuoc_Sua_GioRaVao") == "True";
            chk_VAT_Chi_Tinh_Tong_Tien.Checked = ocpublic.Registry_Get("chk_VAT_Chi_Tinh_Tong_Tien") == "True";
            chkLuuBanTrongKhiTamTinh.Checked = ocpublic.Registry_Get("chkLuuBanTrongKhiTamTinh") == "True";
            chkHien_Thi_DVT.Checked = ocpublic.Registry_Get("chkHien_Thi_DVT") == "True";//2011.11.21
            chk_PrintBill_COM_English.Checked = ocpublic.Registry_Get("chk_PrintBill_COM_English") == "True";//2011.12.01
            chk_Chuyen_DenPhong_KhiThanhToan.Checked = ocpublic.Registry_Get("chk_Chuyen_DenPhong_KhiThanhToan") == "True";//2011.12.08

            string sVATLamTron = ocpublic.Registry_Get("nudVAT_LamTron");//2011.11.24
            nudVAT_LamTron.Value = decimal.Parse(string.Concat("0" + sVATLamTron).Replace("0-", "-"));
            check_loaidichvu.Checked = tbMain.Rows[0]["LOAI_DICH_VU"] + "" == "True";
            check_moket.Checked = tbMain.Rows[0]["MO_KET"] + "" == "True";

            //
            chkNhan_Vien_Phuc_Vu.Checked = ocpublic.Registry_Get("chkNhan_Vien_Phuc_Vu") + "" == "True";//2011.12.19
            chkSo_Khach_Tren_Ban.Checked = ocpublic.Registry_Get("chkSo_Khach_Tren_Ban") + "" == "True";//2011.12.19
            chkHienThi_TongTien_TrenBan.Checked = ocpublic.Registry_Get("chkHienThi_TongTien_TrenBan") + "" == "True";//2011.12.19
            chkCONGNO_NHACUNGCAP.Checked = ocpublic.Registry_Get("chkCONGNO_NHACUNGCAP") + "" == "True";//2012.02.15
            //
            chkApDung_TheoKhu.Checked = ocpublic.Registry_Get("chkApDung_TheoKhu") == "True";//2012.01.02

            if (tbMain.Columns.Contains("MA_MAY"))
                txt_mamay.Text = tbMain.Rows[0]["MA_MAY"] + "";

            string _giamacdinh = "";
            if (tbMain.Columns.Contains("GIA_MAC_DINH"))
                _giamacdinh = tbMain.Rows[0]["GIA_MAC_DINH"] + "";
            if (_giamacdinh == "")
                com_giamacdinh.SelectedIndex = 0;
            else
                com_giamacdinh.SelectedValue = _giamacdinh.Trim();


            chkHIEN_THI_TON_KHO_TREN_MON.Checked = Boolean.Parse("" + tbMain.Rows[0]["HIEN_THI_TON_KHO_TREN_MON"] + "");

            if (tbMain.Columns.Contains("CAPNHAT_TONKHO_HANGHOA"))
            {
                if (tbMain.Rows[0]["CAPNHAT_TONKHO_HANGHOA"] + "" == "")
                    tbMain.Rows[0]["CAPNHAT_TONKHO_HANGHOA"] = false;
                chkCAPNHAT_TONKHO_HANGHOA.Checked = Boolean.Parse(tbMain.Rows[0]["CAPNHAT_TONKHO_HANGHOA"] + "");
            }
            if (tbMain.Columns.Contains("CAPNHAT_TONKHO_NGUYENLIEU"))
            {
                if (tbMain.Rows[0]["CAPNHAT_TONKHO_NGUYENLIEU"] + "" == "")
                    tbMain.Rows[0]["CAPNHAT_TONKHO_NGUYENLIEU"] = false;
                chkCAPNHAT_TONKHO_NGUYENLIEU.Checked = Boolean.Parse(tbMain.Rows[0]["CAPNHAT_TONKHO_NGUYENLIEU"] + "");
            }
            if (tbMain.Columns.Contains("CAPNHAT_LAILO"))
            {
                if (tbMain.Rows[0]["CAPNHAT_LAILO"] + "" == "")
                    tbMain.Rows[0]["CAPNHAT_LAILO"] = false;
                chkCAPNHAT_LAILO.Checked = Boolean.Parse(tbMain.Rows[0]["CAPNHAT_LAILO"] + "");
            }
            
        }
        #endregion

        #endregion

        #region"    các sự kiện _Click của các nút THÊM - SỬA- TÌM KIẾM - THOÁT - tbpDanhSach"

        #region"    btnDSthoat_Click"
        private void btnDSthoat_Click(object sender, EventArgs e)
        {
            //if (MessageBox.Show("Bạn muốn thoát?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
            {
                this.Dispose();
            }

        }
        #endregion

        #endregion

        #region"    các sự kiện _Click của các nút LƯU - XÓA - SỬA  "

        #region"    btnluu_Click"
        private void btnluu_Click(object sender, EventArgs e)
        {
            if (this.save() > 0)
            {
                switch (str_lang)
                {
                    case "vi-VN":
                        LPV_POS.Module.MessageBox_LPV.Show("Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    case "en-US":
                        LPV_POS.Module.MessageBox_LPV.Show("Successful", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                }
                //this.Close();
                cpublic ocpublic = new cpublic();
                ocpublic.get_ngay_lam_viec();
                ocpublic.Load_tbBH_CAU_HINH();
            }
        }

        #endregion
        #region"    save"
        int save()
        {
            int _iReasult = -1;


            thuvien oclsData = new thuvien();//lớp truy xuat du lieu
            _iReasult = oclsData.SP_Update("sp_BH_CAU_HINH",
                 new string[] { "@flag", //"@ID", 
                                    "@NGAY_LAM_VIEC_LA_NGAY_HE_THONG", "@HINH_THUC_BAN_HANG_combo", "@HIEN_THI_TIEN_THOI", 
                                    "@HIEN_THI_TIEN_KHACH_DUA", "@PHAI_VAO_CA_KHI_BAN_HANG", "@KHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH", 

                                    "@KHONG_XOA_MON_SAU_TAM_TINH", "@PHAI_NHAP_LYDO_TRA_MON", "@GOP_MON_CUNG_TEN_KHI_DAT_HANG", 
                                    "@SO_THAP_PHAN", "@KHONG_MO_KET_KHI_THANH_TOAN_ZERO", "@CHO_PHEP_MO_BAN_CA_KHAC", 

                                    "@GIA_MOI_MAT_HANG_KHONG_GOM_THUE", "@THUE_TU_CHON", "@THUE_APDUNG", "@THUE_AN_TAI_CHO", 
                                    "@THUE_MANG_VE", "@TIEN_TIP", "@TIEN_TIP_TUYCHON", "@TIEN_TIP_VAT", "@TIEN_TIP_VAT_PHANTRAM",

                                     "@PHI_DICH_VU","@PHI_DICH_VU_PHANTRAM" ,"@LOAI_DICH_VU",
                                     "@VAT_MAC_DINH","@MO_KET","@MA_MAY","@GIA_MAC_DINH",

                                     "@HIEN_THI_TON_KHO_TREN_MON",
                                     "@CAPNHAT_TONKHO_HANGHOA","@CAPNHAT_TONKHO_NGUYENLIEU",
                                     "@CAPNHAT_LAILO","@PHAI_NHAP_LYDO_HUY_BILL"
                 },
                 new object[] { 1, //ma, 
                                    chkNGAY_LAM_VIEC_LA_NGAY_HE_THONG.Checked,  cboHINH_THUC_BAN_HANG_combo.SelectedIndex, chkHIEN_THI_TIEN_THOI.Checked, 
                                    chkHIEN_THI_TIEN_KHACH_DUA.Checked, chkPHAI_VAO_CA_KHI_BAN_HANG.Checked, chkKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH.Checked, 

                                    chkKHONG_XOA_MON_SAU_TAM_TINH.Checked, chkPHAI_NHAP_LYDO_TRA_MON.Checked, chkGOP_MON_CUNG_TEN_KHI_DAT_HANG.Checked, 
                                    numSO_THAP_PHAN.Value, chkKHONG_MO_KET_KHI_THANH_TOAN_ZERO.Checked, chkCHO_PHEP_MO_BAN_CA_KHAC.Checked, 

                                    chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Checked, chkTHUE_TU_CHON.Checked, chkTHUE_APDUNG.Checked, numTHUE_AN_TAI_CHO.Value, 
                                    numTHUE_MANG_VE.Value, chkTIEN_TIP.Checked, chkTIEN_TIP_TUYCHON.Checked, chkTIEN_TIP_VAT.Checked, numTIEN_TIP_VAT_PHANTRAM.Value,

                                    chkPHI_DICH_VU.Checked, int.Parse("0"+ cboPHI_DICH_VU_PHANTRAM.Text.Trim()), check_loaidichvu.Checked, 
                                    numVAT_MAC_DINH.Value, check_moket.Checked, txt_mamay.Text, com_giamacdinh.SelectedValue+"",

                                    chkHIEN_THI_TON_KHO_TREN_MON.Checked,
                                    chkCAPNHAT_TONKHO_HANGHOA.Checked,chkCAPNHAT_TONKHO_NGUYENLIEU.Checked,
                                    chkCAPNHAT_LAILO.Checked,chkPHAI_NHAP_LYDO_HUY_BILL.Checked
                 });

            cpublic ocpublic = new cpublic();
            ocpublic.Registry_Set(this.Name + cboKHO_MACDINH.Name, cboKHO_MACDINH.SelectedValue);
            ocpublic.Registry_Set("rbtHienThiGioRa", rbtHienThiGioRa.Checked);
            ocpublic.Registry_Set("chkThanh_Toan_Bang_The_Tra_Truoc", chkThanh_Toan_Bang_The_Tra_Truoc.Checked);
            ocpublic.Registry_Set("chkKhongDuoc_Sua_GioRaVao", chkKhongDuoc_Sua_GioRaVao.Checked);
            ocpublic.Registry_Set("chk_VAT_Chi_Tinh_Tong_Tien", chk_VAT_Chi_Tinh_Tong_Tien.Checked);
            ocpublic.Registry_Set("chkLuuBanTrongKhiTamTinh", chkLuuBanTrongKhiTamTinh.Checked);
            ocpublic.Registry_Set("chkHien_Thi_DVT", chkHien_Thi_DVT.Checked);//2011.11.21
            ocpublic.Registry_Set("chk_PrintBill_COM_English", chk_PrintBill_COM_English.Checked);//2011.11.21
            ocpublic.Registry_Set("chk_Chuyen_DenPhong_KhiThanhToan", chk_Chuyen_DenPhong_KhiThanhToan.Checked);//2011.12.08

            ocpublic.Registry_Set("nudVAT_LamTron", nudVAT_LamTron.Value);//2011.11.24
            ocpublic.Registry_Set("chkNhan_Vien_Phuc_Vu", chkNhan_Vien_Phuc_Vu.Checked);//2011.12.19
            ocpublic.Registry_Set("chkSo_Khach_Tren_Ban", chkSo_Khach_Tren_Ban.Checked);//2011.12.19
            ocpublic.Registry_Set("chkHienThi_TongTien_TrenBan", chkHienThi_TongTien_TrenBan.Checked);//2011.12.19
            ocpublic.Registry_Set("chkCONGNO_NHACUNGCAP", chkCONGNO_NHACUNGCAP.Checked);//2012.02.15
            
            #region "   SC_DEFAULT_KHU"
            ocpublic.Registry_Set("chkApDung_TheoKhu", chkApDung_TheoKhu.Checked);//2012.01.02
            DataTable tbDM_KHUVUC = (DataTable)grdPhiDivhVu.DataSource;
            foreach (DataRow dr in tbDM_KHUVUC.Rows)
                ocpublic.Registry_Set("SC_DEFAULT_KHU" + dr["OBJID"], dr["GIA_TRI"]);            
            #endregion

            return _iReasult;
        }

        #endregion

        #endregion

        private void chkTIEN_TIP_CheckedChanged(object sender, EventArgs e)
        {
            chkTIEN_TIP_VAT.Enabled = chkTIEN_TIP.Checked;
            chkTIEN_TIP_TUYCHON.Enabled = chkTIEN_TIP.Checked;
            numTIEN_TIP_VAT_PHANTRAM.Enabled = (chkTIEN_TIP_VAT.Checked && chkTIEN_TIP_VAT.Enabled);
            simpleButton1.Enabled = (chkTIEN_TIP_VAT.Checked && chkTIEN_TIP_VAT.Enabled);

        }
        private void chkTIEN_TIP_VAT_CheckedChanged(object sender, EventArgs e)
        {

            numTIEN_TIP_VAT_PHANTRAM.Enabled = (chkTIEN_TIP_VAT.Checked && chkTIEN_TIP_VAT.Enabled);
            simpleButton1.Enabled = (chkTIEN_TIP_VAT.Checked && chkTIEN_TIP_VAT.Enabled);

        }

        private void chkTIEN_TIP_TUYCHON_CheckedChanged(object sender, EventArgs e)
        {

        }
        //Boolean iCheck = true;
        private void chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE_CheckedChanged(object sender, EventArgs e)
        {
            //if (iCheck)
            //{
            //    iCheck = false;                
            //    chkTHUE_APDUNG.Checked = false;
            //    iCheck = true;
            //}
            chkTHUE_TU_CHON.Enabled = chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Checked;
            chkTHUE_APDUNG.Enabled = chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Checked;
            if (!chkTHUE_APDUNG.Enabled)
            {
                numTHUE_AN_TAI_CHO.ReadOnly = true;
                bton_1.Enabled = false;
                numTHUE_MANG_VE.ReadOnly = true;
                simpleButton3.Enabled = false;
            }
            else
            {
                numTHUE_AN_TAI_CHO.ReadOnly = !chkTHUE_APDUNG.Checked;
                bton_1.Enabled = chkTHUE_APDUNG.Checked;
                numTHUE_MANG_VE.ReadOnly = !chkTHUE_APDUNG.Checked;
                simpleButton3.Enabled = chkTHUE_APDUNG.Checked;
            }
        }

        private void chkTHUE_APDUNG_CheckedChanged(object sender, EventArgs e)
        {
            //if (iCheck)
            //{
            //    iCheck = false;                
            //    chkGIA_MOI_MAT_HANG_KHONG_GOM_THUE.Checked = false;
            //    iCheck = true;
            //}
            numTHUE_AN_TAI_CHO.ReadOnly = !chkTHUE_APDUNG.Checked;
            numTHUE_MANG_VE.ReadOnly = !chkTHUE_APDUNG.Checked;
            bton_1.Enabled = chkTHUE_APDUNG.Checked;
            simpleButton3.Enabled = chkTHUE_APDUNG.Checked;
            //
            chkTHUE_TU_CHON.Checked = false;
        }

        private void chkPHAI_VAO_CA_KHI_BAN_HANG_CheckedChanged(object sender, EventArgs e)
        {
            //chkKHONG_CAN_VAO_CA_KHI_VAO_CHUONG_TRINH.Enabled = chkPHAI_VAO_CA_KHI_BAN_HANG.Checked;
        }

        private void bton_1_Click(object sender, EventArgs e)
        {
            mh_so omh_so = new mh_so("", (int)numTHUE_AN_TAI_CHO.Value);
            //omh_so.txt_ketqua.Text =  + "";//
            omh_so.ShowDialog();
            if (omh_so.DialogResult == DialogResult.OK)
            {
                decimal dc = 0;
                decimal.TryParse(omh_so.txt_ketqua.Text, out dc);
                if (dc > 100 || dc < 0)
                {
                    Mod_messagebox mess = new Mod_messagebox();
                    mess.messagebox_pos("Thông báo", "Phải nhập giá trị từ 0 đến 100", loaithongbao.thongtin.GetHashCode());
                    return;
                }
                numTHUE_AN_TAI_CHO.Value = dc;//
            }
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {

            mh_so omh_so = new mh_so("", (int)numTHUE_MANG_VE.Value);
            //omh_so.txt_ketqua.Text =  + "";//
            omh_so.ShowDialog();
            if (omh_so.DialogResult == DialogResult.OK)
            {
                decimal dc = 0;
                decimal.TryParse(omh_so.txt_ketqua.Text, out dc);
                if (dc > 100 || dc < 0)
                {
                    Mod_messagebox mess = new Mod_messagebox();
                    mess.messagebox_pos("Thông báo", "Phải nhập giá trị từ 0 đến 100", loaithongbao.thongtin.GetHashCode());
                    return;
                }
                numTHUE_MANG_VE.Value = dc;//
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {

            mh_so omh_so = new mh_so("", (int)numTIEN_TIP_VAT_PHANTRAM.Value);
            //omh_so.txt_ketqua.Text = numTIEN_TIP_VAT_PHANTRAM.Value + "";//
            omh_so.ShowDialog();
            if (omh_so.DialogResult == DialogResult.OK)
            {
                decimal dc = 0;
                decimal.TryParse(omh_so.txt_ketqua.Text, out dc);
                if (dc > 100 || dc < 0)
                {
                    Mod_messagebox mess = new Mod_messagebox();
                    mess.messagebox_pos("Thông báo", "Phải nhập giá trị từ 0 đến 100", loaithongbao.thongtin.GetHashCode());
                    return;
                }
                numTIEN_TIP_VAT_PHANTRAM.Value = dc;//
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {

            mh_so omh_so = new mh_so("Số thập phân", (int)numSO_THAP_PHAN.Value);
            //omh_so.txt_ketqua.Text = numSO_THAP_PHAN.Value + "";//
            omh_so.ShowDialog();
            if (omh_so.DialogResult == DialogResult.OK)
            {
                decimal dc = 0;
                decimal.TryParse(omh_so.txt_ketqua.Text, out dc);
                numSO_THAP_PHAN.Value = dc;//
            }
        }

        private void chkPHI_DICH_VU_CheckedChanged(object sender, EventArgs e)
        {
            cboPHI_DICH_VU_PHANTRAM.Enabled = chkPHI_DICH_VU.Checked;
            chkApDung_TheoKhu.Enabled = chkPHI_DICH_VU.Checked;
            grdPhiDivhVu.Enabled = chkPHI_DICH_VU.Checked;
            this.lnkApDung_TheoKhu_CheckedChanged(null, null);
        }

        private void chkGOP_MON_CUNG_TEN_KHI_DAT_HANG_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void chkTHUE_TU_CHON_CheckedChanged(object sender, EventArgs e)
        {
            chkTHUE_APDUNG.Checked = false;
            numVAT_MAC_DINH.ReadOnly = !chkTHUE_TU_CHON.Checked;
            btnVAT_MAC_DINH.Enabled = chkTHUE_TU_CHON.Checked;
            this.lnkApDung_TheoKhu_CheckedChanged(null, null);
        }

        private void btnVAT_MAC_DINH_Click(object sender, EventArgs e)
        {
            mh_so omh_so = new mh_so("VAT", (int)numVAT_MAC_DINH.Value);
            //omh_so.txt_ketqua.Text = numTHUE_AN_TAI_CHO.Value + "";//
            omh_so.ShowDialog();
            if (omh_so.DialogResult == DialogResult.OK)
            {
                decimal dc = 0;
                decimal.TryParse(omh_so.txt_ketqua.Text, out dc);
                if (dc > 100 || dc < 0)
                {
                    Mod_messagebox mess = new Mod_messagebox();
                    mess.messagebox_pos("Thông báo", "Phải nhập giá trị từ 0 đến 100", loaithongbao.thongtin.GetHashCode());
                    return;
                }
                numVAT_MAC_DINH.Value = dc;
            }
        }

        private void bton_mamay_Click(object sender, EventArgs e)
        {
            string str_mamay = new cpublic().loadformso_point(670, 270);
            if (str_mamay != "")
                txt_mamay.Text = str_mamay;

        }

        private void btnDOIGIO_LAMVIEC_TRONGNGAY_Click(object sender, EventArgs e)
        {
            //mh_so omhso = new mh_so("Giờ làm việc trong ngày", (int)numDOIGIO_LAMVIEC_TRONGNGAY.Value);
            //int iso = omhso.ShowForm();
            //if (omhso.DialogResult == DialogResult.OK)
            //{
            //    numDOIGIO_LAMVIEC_TRONGNGAY.Value = iso;
            //}
        }

        private void btnDanhsach_Ngayle_Click(object sender, EventArgs e)
        {
            frmHT_NGAY_LE frm = new frmHT_NGAY_LE();
            frm.ShowDialog();
        }

        private void btnHienThi_BaoCao_Click(object sender, EventArgs e)
        {
            frmHienThi_BaoCao frm = new frmHienThi_BaoCao();
            frm.ShowInTaskbar = false;
            frm.ShowDialog();
        }

        private void btnHienThi_BanHang_Click(object sender, EventArgs e)
        {
            frmHienThi_BanHang frm = new frmHienThi_BanHang();
            frm.ShowDialog();
        }

        private void lnkApDung_TheoKhu_CheckedChanged(object sender, EventArgs e)
        {
            grdPhiDivhVu.Enabled = chkApDung_TheoKhu.Checked && chkApDung_TheoKhu.Enabled;
            cboPHI_DICH_VU_PHANTRAM.Enabled = !chkApDung_TheoKhu.Checked;
        }


    }

}